// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

pub mod text_to_speech {
    use crate::Result;

    /// A builder for [TextToSpeech][crate::client::TextToSpeech].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_texttospeech_v1::*;
    /// # use builder::text_to_speech::ClientBuilder;
    /// # use client::TextToSpeech;
    /// let builder : ClientBuilder = TextToSpeech::builder();
    /// let client = builder
    ///     .with_endpoint("https://texttospeech.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::TextToSpeech;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = TextToSpeech;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::TextToSpeech] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeech>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeech>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [TextToSpeech::list_voices][crate::client::TextToSpeech::list_voices] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_texttospeech_v1::builder;
    /// use builder::text_to_speech::ListVoices;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListVoices {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListVoices(RequestBuilder<crate::model::ListVoicesRequest>);

    impl ListVoices {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeech>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListVoicesRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListVoicesResponse> {
            (*self.0.stub)
                .list_voices(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [language_code][crate::model::ListVoicesRequest::language_code].
        pub fn set_language_code<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.language_code = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListVoices {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TextToSpeech::synthesize_speech][crate::client::TextToSpeech::synthesize_speech] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_texttospeech_v1::builder;
    /// use builder::text_to_speech::SynthesizeSpeech;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> SynthesizeSpeech {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct SynthesizeSpeech(RequestBuilder<crate::model::SynthesizeSpeechRequest>);

    impl SynthesizeSpeech {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeech>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::SynthesizeSpeechRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::SynthesizeSpeechResponse> {
            (*self.0.stub)
                .synthesize_speech(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [input][crate::model::SynthesizeSpeechRequest::input].
        ///
        /// This is a **required** field for requests.
        pub fn set_input<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::SynthesisInput>,
        {
            self.0.request.input = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [input][crate::model::SynthesizeSpeechRequest::input].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_input<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::SynthesisInput>,
        {
            self.0.request.input = v.map(|x| x.into());
            self
        }

        /// Sets the value of [voice][crate::model::SynthesizeSpeechRequest::voice].
        ///
        /// This is a **required** field for requests.
        pub fn set_voice<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::VoiceSelectionParams>,
        {
            self.0.request.voice = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [voice][crate::model::SynthesizeSpeechRequest::voice].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_voice<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::VoiceSelectionParams>,
        {
            self.0.request.voice = v.map(|x| x.into());
            self
        }

        /// Sets the value of [audio_config][crate::model::SynthesizeSpeechRequest::audio_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_audio_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::AudioConfig>,
        {
            self.0.request.audio_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [audio_config][crate::model::SynthesizeSpeechRequest::audio_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_audio_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::AudioConfig>,
        {
            self.0.request.audio_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [advanced_voice_options][crate::model::SynthesizeSpeechRequest::advanced_voice_options].
        pub fn set_advanced_voice_options<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::AdvancedVoiceOptions>,
        {
            self.0.request.advanced_voice_options = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [advanced_voice_options][crate::model::SynthesizeSpeechRequest::advanced_voice_options].
        pub fn set_or_clear_advanced_voice_options<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::AdvancedVoiceOptions>,
        {
            self.0.request.advanced_voice_options = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for SynthesizeSpeech {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TextToSpeech::list_operations][crate::client::TextToSpeech::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_texttospeech_v1::builder;
    /// use builder::text_to_speech::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeech>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TextToSpeech::get_operation][crate::client::TextToSpeech::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_texttospeech_v1::builder;
    /// use builder::text_to_speech::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeech>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod text_to_speech_long_audio_synthesize {
    use crate::Result;

    /// A builder for [TextToSpeechLongAudioSynthesize][crate::client::TextToSpeechLongAudioSynthesize].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_texttospeech_v1::*;
    /// # use builder::text_to_speech_long_audio_synthesize::ClientBuilder;
    /// # use client::TextToSpeechLongAudioSynthesize;
    /// let builder : ClientBuilder = TextToSpeechLongAudioSynthesize::builder();
    /// let client = builder
    ///     .with_endpoint("https://texttospeech.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::TextToSpeechLongAudioSynthesize;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = TextToSpeechLongAudioSynthesize;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::TextToSpeechLongAudioSynthesize] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeechLongAudioSynthesize>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeechLongAudioSynthesize>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [TextToSpeechLongAudioSynthesize::synthesize_long_audio][crate::client::TextToSpeechLongAudioSynthesize::synthesize_long_audio] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_texttospeech_v1::builder;
    /// use builder::text_to_speech_long_audio_synthesize::SynthesizeLongAudio;
    /// # tokio_test::block_on(async {
    /// use lro::Poller;
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.poller().until_done().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> SynthesizeLongAudio {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct SynthesizeLongAudio(RequestBuilder<crate::model::SynthesizeLongAudioRequest>);

    impl SynthesizeLongAudio {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeechLongAudioSynthesize>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::SynthesizeLongAudioRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        ///
        /// # Long running operations
        ///
        /// This starts, but does not poll, a longrunning operation. More information
        /// on [synthesize_long_audio][crate::client::TextToSpeechLongAudioSynthesize::synthesize_long_audio].
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .synthesize_long_audio(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Creates a [Poller][lro::Poller] to work with `synthesize_long_audio`.
        pub fn poller(
            self,
        ) -> impl lro::Poller<
            crate::model::SynthesizeLongAudioResponse,
            crate::model::SynthesizeLongAudioMetadata,
        > {
            type Operation = lro::internal::Operation<
                crate::model::SynthesizeLongAudioResponse,
                crate::model::SynthesizeLongAudioMetadata,
            >;
            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);

            let stub = self.0.stub.clone();
            let mut options = self.0.options.clone();
            options.set_retry_policy(gax::retry_policy::NeverRetry);
            let query = move |name| {
                let stub = stub.clone();
                let options = options.clone();
                async {
                    let op = GetOperation::new(stub)
                        .set_name(name)
                        .with_options(options)
                        .send()
                        .await?;
                    Ok(Operation::new(op))
                }
            };

            let start = move || async {
                let op = self.send().await?;
                Ok(Operation::new(op))
            };

            lro::internal::new_poller(polling_error_policy, polling_backoff_policy, start, query)
        }

        /// Sets the value of [parent][crate::model::SynthesizeLongAudioRequest::parent].
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [input][crate::model::SynthesizeLongAudioRequest::input].
        ///
        /// This is a **required** field for requests.
        pub fn set_input<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::SynthesisInput>,
        {
            self.0.request.input = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [input][crate::model::SynthesizeLongAudioRequest::input].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_input<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::SynthesisInput>,
        {
            self.0.request.input = v.map(|x| x.into());
            self
        }

        /// Sets the value of [audio_config][crate::model::SynthesizeLongAudioRequest::audio_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_audio_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::AudioConfig>,
        {
            self.0.request.audio_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [audio_config][crate::model::SynthesizeLongAudioRequest::audio_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_audio_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::AudioConfig>,
        {
            self.0.request.audio_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [output_gcs_uri][crate::model::SynthesizeLongAudioRequest::output_gcs_uri].
        ///
        /// This is a **required** field for requests.
        pub fn set_output_gcs_uri<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.output_gcs_uri = v.into();
            self
        }

        /// Sets the value of [voice][crate::model::SynthesizeLongAudioRequest::voice].
        ///
        /// This is a **required** field for requests.
        pub fn set_voice<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::VoiceSelectionParams>,
        {
            self.0.request.voice = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [voice][crate::model::SynthesizeLongAudioRequest::voice].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_voice<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::VoiceSelectionParams>,
        {
            self.0.request.voice = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for SynthesizeLongAudio {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TextToSpeechLongAudioSynthesize::list_operations][crate::client::TextToSpeechLongAudioSynthesize::list_operations] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_texttospeech_v1::builder;
    /// use builder::text_to_speech_long_audio_synthesize::ListOperations;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListOperations {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListOperations(RequestBuilder<longrunning::model::ListOperationsRequest>);

    impl ListOperations {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeechLongAudioSynthesize>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::ListOperationsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::ListOperationsResponse> {
            (*self.0.stub)
                .list_operations(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<longrunning::model::ListOperationsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            longrunning::model::ListOperationsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][longrunning::model::ListOperationsRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [filter][longrunning::model::ListOperationsRequest::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [page_size][longrunning::model::ListOperationsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][longrunning::model::ListOperationsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }

        /// Sets the value of [return_partial_success][longrunning::model::ListOperationsRequest::return_partial_success].
        pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.return_partial_success = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListOperations {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TextToSpeechLongAudioSynthesize::get_operation][crate::client::TextToSpeechLongAudioSynthesize::get_operation] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_texttospeech_v1::builder;
    /// use builder::text_to_speech_long_audio_synthesize::GetOperation;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetOperation {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetOperation(RequestBuilder<longrunning::model::GetOperationRequest>);

    impl GetOperation {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TextToSpeechLongAudioSynthesize>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<longrunning::model::GetOperationRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<longrunning::model::Operation> {
            (*self.0.stub)
                .get_operation(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][longrunning::model::GetOperationRequest::name].
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetOperation {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}
